<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="web" uri="http://meerkat.qunar.com/web"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<web:designCss/>
<%@include file="/WEB-INF/include/head.jsp" %>
</head>
<body>
    <div class="wrapper">
        <web:titleBar title="更新用户信息" />

        <div class="main content">
        <form id="userUpdateForm">
            <table class="comm_form_table">
                <tr>
                    <td>ID</td>
                    <td><input type="text" id="id" name="id" value="${user.id}" readonly="true"/></td>
                </tr>
                <tr>
                    <td>用户名</td>
                    <td><input type="text" id="name" name="name" value="${user.name}" readonly="true"/></td>
                </tr>
    	    <tr>
                    <td><span style="color:red;">*</span>账号类型</td>
                    <td>
    		    <input type="radio" id="authType_sso" name="authType" value="0" <c:if test="${user.authType==0}">checked</c:if> 
    			   onclick="$('#pwdWarp').hide()"  /><label for="authType_sso">SSO用户</label>
    		    <input type="radio" id="authType_local" name="authType" value="1" <c:if test="${user.authType==1}">checked</c:if> 
    			   onclick="$('#pwdWarp').show()"/><label for="authType_local">密码用户</label>
                    </td>
                </tr>
                <tr>
                    <td><span style="color:red;">*</span>真实姓名</td>
                    <td><input type="text" id="realname" name="realname" value="${user.realname}" /></td>
                </tr>
                <tr id="pwdWarp" <c:if test="${user.authType==0}">style="display:none;"</c:if>>
                    <td><span style="color:red;">*</span>密码</td>
                    <td><input type="password" id="password" name="password" value="" /></td>
                </tr>
                <tr>
                    <td><span style="color:red;">*</span>所属部门</td>
                    <td><input type="text" id="department" name="department" value="${user.department}" /></td>
                </tr>
                <tr>
                    <td><span style="color:red;">*</span>邮箱</td>
                    <td><input type="text" id="email" name="email" value="${user.email}" /></td>
                </tr>
                <tr>
                    <td><span style="color:red;">*</span>用户组</td>
                    <td>
                        <select class="sel_mult" name="gid" id="gid" multiple="true">
                            <c:forEach items="${groupList}" var="group">
                                <option id="group_option_${group.id}" value="${group.id}">${group.name}</option>
                            </c:forEach>
                        </select>
                        <script>
                            <c:forEach items="${bindGroupList}" var="bindGroupId">
                                document.getElementById("group_option_${bindGroupId}").selected = true;
                            </c:forEach>
                        </script>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="submit" class="button" value="更新"/>
                        <input type="button" class="button" value="关闭" onclick="top.Qadmin.App.Panel.removeTab(Qadmin.FW.Url.getUrlParam('tid'))" />
                    </td>
                </tr>
            </table>
        </form>
        </div>
    </div>
<script>
$(document).ready(function(){
    $('#userUpdateForm').bind("submit", function(){
		if($('#authType_local').attr("checked") == "checked"
		    && $('#password').val() == '') {
		    Qadmin.FW.Dialog.alert({msg : '更新密码用户，密码不能为空!'});
		    return false;
		}
        return Qadmin.FW.Ajax.post({
            url: QG_CONFIG.PATH + 'user/update.htm',
            formId: "userUpdateForm"
        });
    });
});
</script>
<%@include file="/WEB-INF/include/foot.jsp"%>
</body>
</html>